﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TreasureObject : SlotObject
{
    // Start is called before the first frame update
    protected new void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public override bool Move(int dx, int dy, float duration = 0.3f) {
        base.Move(dx, dy, duration);
        slot.SlotState = Slot.State.treasure;
        return true;
    }

    public override bool OnPlayerTouch(Player player, int dx = 0, int dy = 0) {
        StartCoroutine(OpenedCoroutine(0.3f));
        return true;
    }

    IEnumerator OpenedCoroutine(float duration) {
        yield return new WaitForSeconds(duration);
        slot.gridManager.Player.AddTeris();
        Destroy(gameObject);
    }
}
